import 'package:flutter/material.dart';
import 'package:shopping_group/main/lz_mall/model/lz_mall_category_prduct_model.dart';
import 'package:shopping_group/modle/main/ui/details_page.dart';
import 'package:shopping_group/res/colors.dart';
import 'package:shopping_group/res/dimens.dart';
import 'package:shopping_group/utils/route_util.dart';
import 'package:shopping_group/utils/widget_utils.dart';

class EcMallHomeProductWidget extends StatefulWidget {
  final LstCommoSpec lstCommoSpec;
  EcMallHomeProductWidget(this.lstCommoSpec, {Key key}) : super(key: key);

  @override
  _EcMallHomeProductWidgetState createState() => _EcMallHomeProductWidgetState();
}

class _EcMallHomeProductWidgetState extends State<EcMallHomeProductWidget> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
        onTap: () {
          RouteUtil.goParameter(DetailsPage(id: widget.lstCommoSpec.id));
        },
        child: Container(
          padding: EdgeInsets.symmetric(horizontal: 8),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Container(
                child: AspectRatio(
                  aspectRatio: 1,
                  child: FadeInImage.assetNetwork(
                    image: widget.lstCommoSpec.imgUrl,
                    placeholder: 'images/picture_loading.png',
                    fit: BoxFit.contain,
                  ),
                ),
              ),
              Container(
                  padding: EdgeInsets.only(top: 6),
                  child: WidgetUtils.getTextMaxLinesView(
                      widget.lstCommoSpec.name, Colours.text_2222, Dimens.FONT_SIZE_14,
                      maxLines: 1)),
              Container(
                padding: const EdgeInsets.only(right: 8, top: 5),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Container(
                      child: Text(
                        "¥" + widget.lstCommoSpec.outPrice,
                        style: TextStyle(
                          color: Color(0xFFF5544B),
                          fontSize: Dimens.FONT_SIZE_14,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ),
                    Container(
                      alignment: Alignment.centerLeft,
                      child: WidgetUtils.getTextColorView(
                          '已售 ${widget.lstCommoSpec.hadShopCt} 件', Colours.text_2222, Dimens.FONT_SIZE_12,
                          overflow: TextOverflow.clip),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ));
  }
}
